# -*- coding:utf-8 -*-
"""
获取句柄工具,显示当前焦点窗体句柄
@File : GetForeTool.py

@Author: 爸爸

@Date : 2019/6/5

@Desc :
"""
import time
import win32gui


def main():
    num = 0
    while True:
        time.sleep(1)
        hwnd = win32gui.GetForegroundWindow()
        if hwnd != num:
            num = hwnd
            app = win32gui.GetWindowText(hwnd)
            print(hwnd, app)


if __name__ == '__main__':
    main()
